package com.nic.view.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nic.view.R;
import com.nic.view.adapter.CommonCheckAdapter;
import com.nic.view.adapter.MultChooseAdapter;
import com.nic.view.adapter.SingleChooseAdapter;
import com.nic.view.model.CommonChooseBean;

import java.util.List;

/**
 * Created by Administrator on 2018/8/9.
 */

public class MultSpecialView extends LinearLayout {
    public final static int TYPE_SINGLE = 0;//单选
    public final static int TYPE_MULTI = 1;//多选
    private CheckBox cbAll;
    private TextView tvDes;
    private MyGridView gv;
    private SingleChooseAdapter adapter;
    private MultChooseAdapter multChooseAdapter;

    public MultSpecialView(Context context, int selectType) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.item_pop_mult_special, this);
        cbAll = (CheckBox) findViewById(R.id.cb_all);
        tvDes = (TextView) findViewById(R.id.tv_desc);
        gv = (MyGridView) findViewById(R.id.gv);
        cbAll.setVisibility(View.GONE);
        if (TYPE_SINGLE == selectType) {
            adapter = new SingleChooseAdapter();
            gv.setAdapter(adapter);
        } else {
            multChooseAdapter = new MultChooseAdapter();
            gv.setAdapter(multChooseAdapter);
        }
    }

    public SingleChooseAdapter getAdapter() {
        return adapter;
    }

    public MultChooseAdapter getMultiChooseAdapter() {
        return multChooseAdapter;
    }

    public void setSubTitle(String title) {
        tvDes.setText("" + title);
    }

    public void setSingleList(List<CommonChooseBean> list) {
        adapter.setList(list);
    }

    public void setSingleListener(CommonCheckAdapter.OnClickItemSingleListener lis) {
        adapter.setClickItemSingleListener(lis);
    }

    public void setMutiList(List<CommonChooseBean> list) {
        multChooseAdapter.setList(list);
    }

    public void setMultiListener(CommonCheckAdapter.OnClickItemMultiListener lis) {
        multChooseAdapter.setClickItemMultiListener(lis);
    }
}
